package com.java.web;

import com.java.bean.Student;
import com.java.service.StudentService;
import com.java.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: wjr
 * @Description:
 * @Date Created in  2020-09-06 2:22
 * @Modified By:
 */
@WebServlet(value = "/showAll")
public class StudentServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.接收参数

        //1.接受参数
        //2.调取service方法
        StudentService studentService=new StudentServiceImpl();
        List<Student> students = studentService.getAll();
        //3.跳转页面
        req.setAttribute("students",students);
        req.getRequestDispatcher("show.jsp").forward(req,resp);
    }
}
